package com.soft.bams.entity;

import com.soft.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/15
 */
public abstract class Account implements Serializable {
    private Long id;
    private String password;
    private String name;
    private String personId;
    private String email;
    private double balance;

    public Account() {
    }

    public Account(String password, String name, String personId, String email, double balance) {
        this.password = password;
        this.name = name;
        this.personId = personId;
        this.email = email;
        this.balance = balance;
    }

    public Account(Long id, String password, String name, String personId, String email, double balance) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.personId = personId;
        this.email = email;
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", password='" + password + '\'' +
                ", name='" + name + '\'' +
                ", personId='" + personId + '\'' +
                ", email='" + email + '\'' +
                ", balance=" + balance +
                '}';
    }

    // 存款
    public final Account deposit(double amount) {
        this.balance += amount;
        return this;
    }

    // 取款
    public abstract Account withdraw(double amount) throws BalanceNotEnoughException;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
